package com.troll.wanandroid.adapter.home

import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.troll.eth.ex.load
import com.troll.eth.util.LPUtil
import com.troll.eth.util.MATCH
import com.troll.wanandroid.model.BannerBean
import com.youth.banner.adapter.BannerAdapter

/**
 *
 * @Author:   TangPeng
 * @Time:     6/4/21
 * @Remark:
 */
class HomeHeadBannerAdapter(list: MutableList<BannerBean>?) :
    BannerAdapter<BannerBean, HomeHeadBannerAdapter.BannerHolder>(list) {

    override fun onCreateHolder(parent: ViewGroup?, viewType: Int): BannerHolder {
        val iv = ImageView(parent?.context)
        iv.layoutParams = LPUtil.viewGroup(MATCH, MATCH)
        iv.scaleType = ImageView.ScaleType.CENTER_CROP
        return BannerHolder(iv)
    }

    override fun onBindView(holder: BannerHolder?, data: BannerBean?, position: Int, size: Int) {
        holder?.iv?.load(data?.imagePath)
    }

    inner class BannerHolder : RecyclerView.ViewHolder {
        var iv: ImageView? = null

        constructor(view: View) : super(view) {
            this.iv = view as ImageView
        }
    }
}